<script setup>
import {ref} from "vue";
const num = ref('');
let x = parseInt(Math.random()*100+1);
console.log(x);
const info = ref('');
const guess = ()=>{
  if (num.value>x){
    info.value = '猜大了';
  }else if(num.value<x){
    info.value = '猜小了';
  }else {
    info.value = '猜对了';
  }
}
</script>

<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入你要猜的数字" v-model="num">
  <button @click="guess()">猜一猜</button>
  <h3>{{info}}</h3>
</template>

<style scoped>

</style>